//gui_chung_dll a program by NGUYEN.Chung (freeware 2012);
//#Include Once "windows.bi"

#define dllimport extern "C" __declspec(dllimport) 
#define DLLsub dllimport void
#define DLLfunction dllimport

typedef unsigned int uint; 
typedef void (__cdecl * myfunction)();

uint guiwindowdefautflag=WS_SYSMENU | WS_MINIMIZEBOX ; //'| WS_DLGFRAME '| WS_MAXIMIZEBOX 

//#Inclib "gui_chung_dll"

DLLsub guireset();

DLLfunction HBITMAP guiloadimage(const char* filename );
          //'Supported types; bmp,emf,wmf,jpg,ico,gif
DLLfunction HBITMAP guiloadbmp(const char* filename );

DLLfunction HBITMAP guiloadbmpdib(const char* filename );

DLLfunction void* guigetbmpdibbits(HBITMAP hbmp);  

DLLsub button(const char* controlname ,const char* controltext ,myfunction controlsub , 
	        uint controlx ,uint controly ,uint controldx ,uint controldy ,
	        uint userflags  = 0);
 
DLLfunction uint getguiindex(const char* controlname );  
 
DLLfunction HWND getguih(const char* controlname );  

DLLfunction char* getguihname(HWND guihwin ); 

DLLsub printguih(HWND hcontrol ,const char* controltext );

DLLsub printgui(const char* controlname ,const char* controltext );

DLLfunction char* guigettexth(HWND hcontrol ); 

DLLfunction char* guigettext(const char* controlname );  
 
DLLsub guirefresh();

DLLsub guirefreshwindow(const char* windowname );

DLLsub guirefreshcontrolh(HWND hcontrol );

DLLsub guirefreshcontrol(const char* controlname );

DLLsub setedittextfont(uint fontnum ,uint size  = 0,byte italic  = FALSE);
	
DLLsub setstatictextfont(uint fontnum ,uint size  = 0,byte italic  = FALSE);

DLLsub setlistboxfont(uint fontnum ,uint size  = 0,byte italic  = FALSE);

DLLsub setbuttonfont(uint fontnum ,uint size  = 0,byte italic  = FALSE);

DLLsub guiclosewindow(const char* windowname );

DLLsub graphicbox(const char* controlname ,  
	        uint controlx ,uint controly ,uint controldx ,uint controldy ,
	        const char* graphtype  ="gfx",uint userflags  = 0);

DLLfunction void* getguigfxbuffer(const char* controlname );

DLLsub guiscan();

DLLsub guiwait();

DLLsub guibackgroundcolor(uint r,uint g ,uint b );

DLLsub guiedittextbackcolor(uint r ,uint g ,uint b );

DLLsub guilistboxbackcolor(uint r ,uint g ,uint b );

DLLsub guiedittextinkcolor(uint r ,uint g ,uint b );

DLLsub guilistboxinkcolor(uint r ,uint g ,uint b );

DLLsub guistatictextinkcolor(uint r ,uint g ,uint b );

DLLsub openwindow (const char* windowname ,const char* windowtext , 
                uint x ,uint y ,uint dx ,uint dy ,
                uint windowtype  = guiwindowdefautflag,
                uint windowtypeex  = 0);
DLLsub guiclose(const char* opt  = "nomsg");

DLLsub guiquit(const char* opt  = "nomsg");

DLLsub trapclose(const char* windowname ,myfunction closesub );	

DLLsub trapresize(const char* windowname ,myfunction resizesub );	

DLLsub trapkeyboard(const char* windowname ,myfunction keyboardsub );	

DLLsub trapLeftmouse(const char* controlname ,myfunction mousesub );	

DLLsub trapRightmouse(const char* controlname ,myfunction mousesub );	

DLLsub trapLeftmouseup(const char* controlname ,myfunction mousesub );	

DLLsub trapRightmouseup(const char* controlname ,myfunction mousesub );	

DLLsub trapmovemouse(const char* controlname ,myfunction mousesub );	

DLLsub enableguih(HWND hcontrol );

DLLsub disableguih(HWND hcontrol );

DLLsub enablegui(const char* controlname );

DLLsub disablegui(const char* controlname );

DLLsub showguih(HWND hcontrol );

DLLsub hideguih(HWND hcontrol );

DLLsub showgui(const char* controlname );

DLLsub hidegui(const char* controlname );

DLLsub radiobutton(const char* controlname ,const char* controltext ,myfunction controlsub , 
	        uint controlx ,uint controly ,uint controldx ,uint controldy );
 
DLLsub checkbox(const char* controlname ,const char* controltext ,myfunction controlsub , 
	        uint controlx ,uint controly ,uint controldx ,uint controldy );
 
DLLsub iconbutton(const char* controlname ,const char* iconfile ,myfunction controlsub , 
	        uint controlx ,uint controly ,uint controldx ,uint controldy );
 
DLLsub bmpbutton(const char* controlname ,const char* bmpfile ,myfunction controlsub ,
	        uint controlx ,uint controly ,uint controldx ,uint controldy );

DLLsub staticicon(const char* controlname ,const char* iconfile ,
	        uint controlx ,uint controly ,uint controldx ,uint controldy );

DLLsub staticbmp(const char* controlname ,const char* bmpfile ,
	        uint controlx ,uint controly ,uint controldx ,uint controldy );

DLLsub statictext(const char* controlname ,const char* controltext , 
	        uint controlx ,uint controly ,uint controldx ,uint controldy ,
	        uint userflags  = 0);
 
DLLsub edittext(const char* controlname ,const char* controltext ,myfunction controlsub ,
	        uint controlx ,uint controly ,uint controldx ,uint controldy ,
	        uint userflags  = 0);

DLLsub combobox(const char* controlname ,myfunction controlsub , 
	        uint controlx ,uint controly ,uint controldx ,uint controldy );

DLLsub reloadcombo(const char* comboname ,const char* liste[],uint nliste=400 );
 
DLLsub addcombo(const char* comboname ,const char* liste );
 
DLLsub selectcombotext(const char* comboname ,const char* item ,const char* liste[],uint nliste=400 );
 
DLLsub selectcomboindex(const char* comboname ,uint i );
 
DLLsub getcomboindex(const char* comboname ,uint* i );
 
DLLsub removecombo(const char* comboname ,uint i );
 
DLLsub resetcombo(const char* comboname );

DLLfunction char* getcombotext(const char* comboname ,const char* liste[],uint nliste=400 ); 

DLLsub setcheckbox(const char* checkname );
 
DLLsub unsetcheckbox(const char* checkname );

DLLsub listbox(const char* controlname ,myfunction controlsub , 
	        uint controlx ,uint controly ,uint controldx ,uint controldy , 
	        uint userflags  = 0);

DLLsub reloadlistbox(const char* listboxname ,const char* liste[],uint nliste=400 );
 
DLLsub selectlistboxtext(const char* listboxname ,const char* item ,const char* liste[],uint nliste=400 );
 
DLLsub addlistbox(const char* listboxname ,const char* text );

DLLfunction char* getlistboxtextbyindex(const char* listboxname ,uint index ); 
 
DLLsub getlistboxindex(const char* listboxname ,uint* i );
 
DLLsub selectlistboxindex(const char* listboxname ,uint i );
 
DLLfunction char* getlistboxtext(const char* listboxname ); 

DLLfunction uint guiiswindowopen(const char* windowname );

DLLfunction uint guiisopen(const char* windowname );

DLLsub guigetwindowpos(const char* windowname ,uint* x ,uint* y , 
	                 uint* dx ,uint* dy );

DLLsub guimovewindow(const char* windowname ,uint x ,uint y ,
	               uint dx ,uint dy );

DLLsub guimovecontrol(const char* controlname ,uint x ,uint y , 
	               uint dx  = 0,uint dy  = 0);

DLLsub guishowwindow(const char* windowname );

DLLsub guisetfocus(const char* windowname );

DLLsub addusersub(uint i ,myfunction usersub  );

DLLsub changeusersub(uint i ,myfunction usersub );

DLLsub addmenu(const char* controlname ,const char* controltext ,
	           uint controlflag  = MF_STRING | MF_POPUP); 

DLLsub addmenuitem(const char* controlname ,const char* controltext ,myfunction controlsub ,
	             uint controlflag  = MF_STRING); 

DLLsub setcheckmenu(const char* menuname ,uint i );

DLLsub uncheckmenu(const char* menuname ,uint i );

DLLsub enablemenu(const char* menuname ,uint i );

DLLsub disablemenu(const char* menuname ,uint i );

DLLsub setmenutext(const char* menuname ,uint i ,const char* text );

DLLfunction int guitestkey(uint ikey );

//DLLfunction guiword(t , i , s ); 

DLLfunction char* filedialog(const char* titre ,const char* filtre  = ""); 

DLLsub guigltext(const char* text );

DLLsub guistartOpenGL (const char* controlname ); //'start opengl , only one at a time

DLLsub guicloseOpenGL();//'close and purge opengl

DLLsub guirefreshopenGL();

DLLfunction HBITMAP guicreateDIBbmp(uint x ,uint y );

DLLfunction uint guiloadtexture(const char* filename ,uint maxcolor =255, uint alph =127);  //bmp jpg gif ico

DLLsub guideletetexture(uint itexture );

DLLfunction char* guicurrentcontrolname(); 

DLLsub guisleep(int ms );

DLLsub guigetbmpXY(HDC bmpdc,uint* bmpx,uint* bmpy); 

DLLsub  guidrawcolor (uint r,uint g,uint b,uint a);

DLLsub  guidrawbackcolor (uint r,uint g,uint b,uint a);

DLLsub  guidrawstringbuffer (void* buffer,int x,int y, const char* text); 

DLLsub  guidrawstring (const char* wingraph, int x,int y, const char* text);  
 
DLLsub  guidrawcmdbuffer (void* buffer, const char* cmd);

DLLsub  guidrawcmd (const char* wingraph ,const char* cmd); 
	            
DLLsub  guidrawlinebuffer (void* buffer, int x1,int y1,int x2,int y2); 
	             
DLLsub  guidrawline (const char* wingraph, int x1,int y1,int x2,int y2); 
	              
DLLsub  guidrawboxbuffer (void* buffer, int x1,int y1,int x2,int y2,uint fill=0); 

DLLsub  guidrawbox (const char* wingraph, int x1,int y1,int x2,int y2,uint fill=0); 
	            
DLLsub  guidrawcirclebuffer (void* buffer, int x,int y,uint r,uint fill=0); 

DLLsub  guidrawcircle (const char* wingraph, int x,int y,uint r,uint fill=0);

DLLsub  guidrawpointbuffer (void* buffer,int x,int y);

DLLsub  guidrawpoint (const char* wingraph , int x,int y);
 